//**************************************************************
//  CoinFlips.java   Author: Tang Caiming
//
//  利用第5章例子5.4的Coin类，编写抛制硬币100次并奇数的程序.
//**************************************************************

public class PP6_6
{
   //----------------------------------------------------------
   //  创建一个硬币对象，翻转其100次，输出其每面朝上的次数.
   //----------------------------------------------------------
   public static void main(String[] args)
   {
      Coin myCoin = new Coin();
      int num, head = 0, tail = 0;

      for (num = 0; num < 100; num++)
      {

         myCoin.flip();

         if (myCoin.isHeads())
            head++;
         else
            tail++;
      }

      System.out.println("正面朝上次数：" + head + "\n" + "反面朝上次数：" + tail);
   }
}
